package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemTableInfoBo;
import com.cw.jeeyt.dao.model.system.SystemTableInfoDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 系统表信息转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemTableInfoConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemTableInfoBo do2Bo(SystemTableInfoDo model) {
        if (model == null) {
            return new SystemTableInfoBo();
        }
        SystemTableInfoBo bo = new SystemTableInfoBo();
        bo.setId(model.getId());
        bo.setPkId(model.getPkId());
        bo.setModuleId(model.getModuleId());
        bo.setTableName(model.getTableName());
        bo.setTableCode(model.getTableCode());
        bo.setTableCodeMapping(model.getTableCodeMapping());
        bo.setTableEntityCode(model.getTableEntityCode());
        bo.setTableEntityCodeMapping(model.getTableEntityCodeMapping());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        bo.setPkIdDataType(model.getPkIdDataType());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemTableInfoDo bo2Do(SystemTableInfoBo bo) {
        if (bo == null) {
            return new SystemTableInfoDo();
        }
        SystemTableInfoDo model = new SystemTableInfoDo();
        model.setId(bo.getId());
        model.setPkId(bo.getPkId());
        model.setModuleId(bo.getModuleId());
        model.setTableName(bo.getTableName());
        model.setTableCode(bo.getTableCode());
        model.setTableCodeMapping(bo.getTableCodeMapping());
        model.setTableEntityCode(bo.getTableEntityCode());
        model.setTableEntityCodeMapping(bo.getTableEntityCodeMapping());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        model.setPkIdDataType(bo.getPkIdDataType());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemTableInfoBo> doList2BoList(List<SystemTableInfoDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemTableInfoConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemTableInfoDo> boList2DoList(List<SystemTableInfoBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemTableInfoConverter::bo2Do));
    }
}
